import com.vader.common.GeneratorApplication;
import com.vader.common.entity.DO.ColumnInfoDO;
import com.vader.common.entity.DO.GeneratorConfigDO;
import com.vader.common.service.GeneratorService;
import com.vader.common.utils.GeneratorUtil;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.IOException;
import java.util.List;

/**
 * @author Vader
 * @date 2021/10/5
 **/
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,classes = GeneratorApplication.class)
public class test {
    @Autowired
    private GeneratorService generatorService;

    @Test
    public void generatorTest() throws IOException {
        String tableName = "base_user_info";
        String pack = "com.vader";
        String author = "Vader";
        List<ColumnInfoDO> columnInfos = generatorService.getColumns(tableName);
        GeneratorConfigDO generatorConfigDO = new GeneratorConfigDO();
        generatorConfigDO.setPack(pack);
        generatorConfigDO.setAuthor(author);
        generatorConfigDO.setTableName(tableName);
        GeneratorUtil.generatorCode(columnInfos, generatorConfigDO);
    }

}
